package com.lagou.homework3;



public class Staff {
    private String name;
    private int age;

    public Staff() {
    }

    public Staff(String name, int age) /*throws AgeException, NullPointerException*/ {
        setName(name);
        setAge(age);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) /*throws NullException*/{
        if (name == null || "".equals(name)) {
            try {
                throw new NullException("名字不能为空");
            } catch (NullException e) {
                e.printStackTrace();
            }
        } else {
            this.name = name;
        }
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) /*throws AgeException*/{
        if (age > 18 && age < 150) {
            this.age = age;
        } else {
            try {
                throw new AgeException("年龄异常！");
            } catch (AgeException e) {
                e.printStackTrace();
            }
        }
    }

    /*@Override*/
    /*public String toString() {*/
    /*    return "Staff{" +*/
    /*            "name='" + name + '\'' +*/
    /*            ", age=" + age +*/
    /*            '}';*/
    /*}*/
}
